package com.zq.zhufengfm.fragments;


import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.zq.zhufengfm.adapter.BaseFragmentPagerAdapter;
import com.zq.zhufengfm.fragments.customer.CustomAttationFragment;
import com.zq.zhufengfm.fragments.customer.CustomCollectionFragment;
import com.zq.zhufengfm.fragments.customer.CustomHistoryFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class CustomerTingFragment extends Fragment {

    private ViewPager viewPager;

    public CustomerTingFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.base_viewpager_tablayout, container, false);

        //tabLayout的加载
        TabLayout tabLayout = (TabLayout) view.findViewById(R.id.base_tablayout);
        //2.ViewPager的加载
        viewPager = (ViewPager) view.findViewById(R.id.base_viewpager);

        List<BaseFragment> fragments = new ArrayList<BaseFragment>();
        fragments.add(new CustomAttationFragment());
        fragments.add(new CustomCollectionFragment());
        fragments.add(new CustomHistoryFragment());

         BaseFragmentPagerAdapter baseFragmentPagerAdapter = new BaseFragmentPagerAdapter(
                getChildFragmentManager(),fragments);

        viewPager.setAdapter(baseFragmentPagerAdapter);

        tabLayout.setupWithViewPager(viewPager);


        return view;
    }


}
